Skip to content

Fix: Version header in response Vary#1637

Open
arctic-char wants to merge 3 commits into
oxidecomputer:mainfrom
arctic-char:fix/version-header-in-vary
Open

Fix: Version header in response Vary#1637
arctic-char wants to merge 3 commits into
oxidecomputer:mainfrom
arctic-char:fix/version-header-in-vary

Conversation

@arctic-char

Copy link
Copy Markdown

Summary

Fixes #1628.

When using ClientSpecifiesVersionInHeader, responses can differ based on the version request header, but the server wasn't setting the Vary response header accordingly. Caching proxies could then serve a response cached for one API version to a client requesting another.

This adds DynamicVersionPolicy::response_vary_on() (default: none) so policies can declare which request headers affect the response. ClientSpecifiesVersionInHeader returns its configured header name. VersionPolicy::add_vary_headers() appends those fields to Vary without duplicating existing entries and skips when Vary: * is already set. The server applies this to all responses (including version-policy errors) in http_request_handle_wrap, matching the existing gzip Accept-Encoding pattern.

Testing

  • Unit tests for add_vary_on_header (basic add, no duplicate, skip on Vary: *)
  • test_versions integration test asserts Vary includes the version header on success and error responses
  • cargo test -p dropshot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClientSpecifiesVersionInHeader doesn't set Vary header

1 participant